<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户信息管理</title>
<link href="${pageContext.request.contextPath}/css/client/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/admin-all.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
    <script src="${pageContext.request.contextPath}/js/layui/layui.all.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery/jquery-3.3.1.js"></script>
</head>

<body>
<div class="alert alert-info">客户信息管理</div>

<form action="query_cus">
<div class="button_bar">
  <input type="button" class="common_button"   onclick="layer.alert('欢迎使用!');" value="帮助"/>
  <input type="submit" class="common_button"  value="查询"/>
</div>

<table class="query_table">
   <tr>
       <th>客户编号</th>
       <td><input type="text" name="cus_id"/></td>
       <th>名称</th>
       <td><input type="text" name="cus_name"/>
       </td><th>地区</th>

   <td><select name="cus_area">
           <option name="cus_area" value="全部">全部</option>
		   <option name="cus_area" value="华北">华北</option>
		   <option name="cus_area" value="华南">华南</option>
		   <option name="cus_area" value="东北">东北</option>
		   <option name="cus_area" value="西部">西部</option>
       </select>
   </td>
   </tr>
   <tr>
       <th>客户经理</th>
       <td><input type="text" name="cus_manager"/>
       </td><th>客户等级</th>
   <td><select name="cus_rank">
          <option name="cus_rank" value="全部">全部</option>
		  <option name="cus_rank" value="普通客户">普通客户</option>
		  <option name="cus_rank" value="大客户">大客户</option>
		  <option name="cus_rank" value="长期合作伙伴">长期合作伙伴</option>
       </select>
   </td>
   </tr>
</table>
</form>

</br>
<table class="data_table"  cellpadding="0" cellspacing="1">
    <tr>
	    <th>序号</th>
		<th>客户编号</th>
		<th>名称</th>
		<th>地区</th>
		<th>客户经理</th>
		<th>客户等级</th>
		<th>操作</th>
	</tr>
<c:forEach items="${pageInfo.list}" var="customer" varStatus="status">
	<tr>
	    <td>${status.index+1}</td>
		<td>${customer.cus_id}</td>
		<td>${customer.cus_name}</td>
		<td>${customer.cus_area}</td>
		<td>${customer.cus_manager}</td>
		<td>${customer.cus_rank}</td>
		<td >
		     <img class="op_button" src="${pageContext.request.contextPath}/images/bt_edit.gif" onclick="upd_customer('${customer.cus_id}')" title="编辑" />
			 <img class="op_button" src="${pageContext.request.contextPath}/images/bt_linkman.gif" onclick="show_contact('${customer.cus_id}')" title="联系人"/>
			 <img class="op_button" src="${pageContext.request.contextPath}/images/bt_del.gif" onclick="del(${customer.id})" title="删除" />
		</td>
	</tr>
</c:forEach>
</table>
<div class="page_down">
    <div class="page_down_dv1"> 共有<strong>${pageInfo.total} </strong> 条记录，当前第<strong> ${pageInfo.pageNum} </strong> 页，共 <strong>${pageInfo.pages}</strong> 页 </div>

    <div class="page_down_dv2">
        <ul>
            <li>                   <!--首页-->
                <a href="javascript:void(0)" onclick="first()">
                    <img src="${pageContext.request.contextPath}/images/main_54.gif" width="40" height="15" />
                </a>
            </li>


            <li>                  <!--上一页-->
                <a href="javascript:void(0)" onclick="pre()" >
                    <img src="${pageContext.request.contextPath}/images/main_56.gif" width="40" height="15" />
                </a>
            </li>

            <li>                <!--下一页-->
                <a href="javascript:void(0)" onclick="next()" >
                    <img src="${pageContext.request.contextPath}/images/main_58.gif" width="40" height="15" />
                </a>
            </li>

            <li>                <!--尾页-->
                <a href="javascript:void(0)" onclick="last()" >
                    <img src="${pageContext.request.contextPath}/images/main_60.gif" width="40" height="15" />
                </a>
            </li>

            <li><span>转到</span></li>
            <li>
                <input type="text" style=" width:25px;" id="pageNum" onblur="forwardTo()" />
            </li>
            <li><span>页</span></li>
            <li>
                <a href="javascript:void(0)" onclick="forwardTo()">
                    <img src="${pageContext.request.contextPath}/images/main_62.gif" width="26" height="15" />
                </a>
            </li>
        </ul>
    </div>
</div>

<script type="text/javascript">
    function del(id) {
        layer.confirm('确定要删除?',{
                btn: ['确定','取消'] }, //按钮
            function(){
                window.location.href = "del_cus?id="+id+"&pageNum="+${pageInfo.pageNum};
            },function(){
                layer.msg('的确很重要', {icon: 1});
            })
    }
</script>

<script type="text/javascript">
    //js 传递 字符串 实参需要带 ''   ==>  onclick="show_contact('${customer.cus_id}')"
    function show_contact(id) {
      //  layer.alert(id);
        window.location.href = "show_contact?cus_id="+id;
    }

    function upd_customer(id) {
        layer.alert(id);
        window.location.href = "upd_customer?cus_id="+id+"&type=query";
    }
</script>



<!--pagehelper 分页 前台参数-->
<script type="text/javascript">

    //首页
    function first() {
        var pageNum = ${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1;
        window.location.href = "cusInfo?pageNum="+pageNum;
    }

    //上一页
    function pre() {
        var pageNum = ${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1;
        window.location.href = "cusInfo?pageNum="+pageNum;
    }

    //下一页
    function next() {
        var pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages};
        window.location.href = "cusInfo?pageNum="+pageNum;
    }

    //尾页
    function last() {
        var pageNum=${pageInfo.pages};
        window.location.href = "cusInfo?pageNum="+pageNum;
    }

    //跳转
    function forwardTo() {
        var pageNum=$("#pageNum").val();
        if(pageNum.trim()=="" || (pageNum.trim()> ${pageInfo.pages} ) || (pageNum.trim() < 1) ){
            layer.alert("请输入正确的页码!")
        }else{
            window.location.href = "cusInfo?pageNum="+pageNum;
        }

    }
</script>
</body>
</html>
